package com.newture.lxz.generator.component.meta;

import org.apache.commons.lang3.StringUtils;

import java.util.HashSet;
import java.util.Set;

/**
 * @author xiao.hu
 * @date 2021-08-07
 * @apiNote
 */
public class TableMeta {
    private String tableName;
    private Set<String> columnName = new HashSet<>();

    public void put(String tableName, String columnName) {
        if(StringUtils.isBlank(this.tableName)) {
            this.tableName = tableName;
        }
        else if(!this.tableName.equals(tableName)) {
                throw new IllegalArgumentException(
                        String.format("table names are inconsistent, exist: %s, parameter: %s"
                                , this.tableName, tableName));
        }

        this.columnName.add(columnName);
    }

    public String getTableName() {
        return tableName;
    }

    public Set<String> getColumnName() {
        return columnName;
    }
}
